<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
      <ul>
        <li v-for="cate in cates" :key="cate.id">
          <span>{{cate.name}}</span>
          <img :src="cate.icon" alt="">
        </li>
      </ul>
  </div>
  <script src="./vue.js"></script>
  <script src="./axios.js"></script>
  <script>
   
    const vm = new Vue({
      el: '#app',
      data:{
        cates:[]
      },
      created() {
        this.fetchCates();
      },
      methods:{
       async fetchCates(){
          // 发送请求
          /* axios.get('https://api.it120.cc/conner/shop/goods/category/all?a=10').then(res=>{
            console.log(res)
            if(res.data.code === 0){
              this.cates = res.data.data
            }
          }).catch(err=>{

          }) */
          /* axios.get('https://api.it120.cc/conner/shop/goods/category/all',{
            params: {
              a:10
            }
          }).then(res=>{
            console.log(res)
          }) */
          const ret = await axios.get('https://api.it120.cc/conner/shop/goods/category/all',{
            params: {
              a:10
            }
          })
          console.log(ret)
          if(ret.data.code === 0){
            this.cates = ret.data.data
          }
        }
      }
    })
  </script>
</body>
</html>